﻿using Microsoft.Phone.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace DDU.UX
{
    public class UXTextButton : Button
    {
        public UXTextButton()
        {
            DefaultStyleKey = typeof(UXTextButton);

            Click -= UXTextMenu_Click;
            Click += UXTextMenu_Click;

        }

        void UXTextMenu_Click(object sender, RoutedEventArgs e)
        {
            if (Uri != null)
            {
                PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual;
                frame.Navigate(Uri);
            }
            
        }

        #region Uri
        [Category("Common Properties")]
        public Uri Uri
        {
            get { return GetValue(UriProperty) as Uri; }
            set { SetValue(UriProperty, value); }
        }

        public static readonly DependencyProperty UriProperty = DependencyProperty.Register(
            "Uri",
            typeof(Uri),
            typeof(UXTextButton),
            new PropertyMetadata(null)); 
        #endregion
    }
}
